package ${model.packageName}.${model.modulePackage}.dao;

import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.apa.biz.common.CustomRepostory;
import com.apa.biz.common.CustomRowBounds;
import ${model.packageName}.${model.modulePackage}.entity.${model.model}Entity;
/**
* ${model.model}Dao:${model.comment} 数据持久层接口
* @author ${model.author} ${date} 
*/
@Repository
public interface ${model.model}Dao extends JpaRepository<${model.model}Entity, Long>,
		JpaSpecificationExecutor<${model.model}Entity>,CustomRepostory<Map<String, Object>>{
    
    
#foreach($field in $fieldList)
#if($field.findBy)

	/**
	 * 通过${field.comment}${field.fieldUp}查询实体
	 * @author ${model.author} ${date}
	 * @param code
	 * @return
	 */
    @Query("from ${model.model}Entity where ${field.field}=:${field.field} and delFlag=0")
	${model.model}Entity findBy${field.fieldUp}(@Param("${field.field}") String ${field.field});
#end
#if($field.findAllBy)

	/**
	 * 通过${field.comment}${field.fieldUp}查询所有实体
	 * @author ${model.author} ${date}
	 * @param code
	 * @return
	 */
    @Query("from ${model.model}Entity where ${field.field}=:${field.field} and delFlag=0")
	List<${model.model}Entity> findAllBy${field.fieldUp}(@Param("${field.field}") String ${field.field});
#end
#end
	
	/**
	 * 查询所有实体
	  * @author ${model.author} ${date}
	 * @param code
	 * @return
	 */
    @Query("from ${model.model}Entity where delFlag=0")
	List<${model.model}Entity> findAll();

	/**
	 * 逻辑删除
	  * @author ${model.author} ${date}
	 * @param code
	 * @return
	 */
	@Modifying
	@Query("update ${model.model}Entity set delFlag=1 where code=:code")
	int deleteByCode(@Param("code") String code);
	
    /**
	 * 根据条件查询所有,非分页
	  * @author ${model.author} ${date}
	 * @param code
	 * @return
	 */
	public List<Map<String, Object>> findAllByParams(Map<String, Object> params);

}